package com.itany.corejava.code06_面向对象.抽象类;

/**
 * @author 石小俊
 * @date 2024年01月17日 9:41
 */
public class Test01_抽象类 {
    public static void main(String[] args) {
        // 父类不允许实例化,一般只用于被子类继承
        // Person person = new Person();
        Person man = new Man("admin",8000);
        man.test();
        // Person woman = new WoMan();
    }
}
abstract class Person{
    private String name;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    // 父类方法不进行实现
    // 保证子类必须重写该方法
    public abstract void show();

    public abstract void print();

    public void test(){
        System.out.println("这是一个普通方法");
    }
}
class Man extends Person{
    private double salary;

    public Man(String name, double salary) {
        super(name);
        this.salary = salary;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
    public void show(){
        System.out.println("我是一个男人");
    }

    @Override
    public void print() {

    }
}
abstract class WoMan extends Person{
    public void show(){
        System.out.println("我是一个女人");
    }

}
